package process.visitor;

import process.ast.Action;
import process.ast.BeginState;
import process.ast.EndState;
import process.ast.Process;
import process.ast.States;
import process.ast.Workflow;

public class VisitorImpl implements Visitor {

	public void visit(Process node) {
		System.out.println(node.getId());
		for (Workflow workflow : node.getWorkflows()) {
			workflow.accept(this);
		}
	}

	public void visit(Workflow node) {
		System.out.println("[" + node.getId() + "]");
		for (Action action : node.getActions()) {
			action.accept(this);
		}
	}

	public void visit(Action node) {
		// System.out.println(node.getId());
		for (States state : node.getStates()) {
			state.accept(this);
		}
	}

	public void visit(States node) {
		String out = node.getActionId() + " = ";
		for (String string : node.getBeginStates()) {
			out += string + ", ";
		}
		out = out.substring(0, out.length() - 2);
		System.out.println(out + " -> " + node.getEndState());
	}

	public void visit(EndState node) {
		
	}

	public void visit(BeginState node) {
		
	}

}
